package com.example.q_kang.hhh.util;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.example.q_kang.hhh.R;
import com.sskj.base.base.App;
import com.sskj.base.utils.CheckUtil;
import com.sskj.base.utils.ClickUtil;
import com.sskj.base.utils.ToastUtil;


/**
 * <pre>
 *     author : 吕志豪
 *     e-mail : 1030753080@qq.com
 *     time   : 2018/04/10
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class TipUtil {
    public static MaterialDialog getTip(Context context, String content, OnTipSure onTipSure) {
        return new MaterialDialog.Builder(context)
                .title(App.INSTANCE.getString(R.string.strTipUtil200))
                .content(content)
                .positiveText(App.INSTANCE.getString(R.string.strTipUtil201))
                .negativeText(App.INSTANCE.getString(R.string.strTipUtil202))
//                .negativeText("")
                .onAny((dialog, which) -> {
                    if (which == DialogAction.POSITIVE) {
                        dialog.dismiss();
                        onTipSure.onSure();
                    } else if (which == DialogAction.NEGATIVE) {
                        dialog.dismiss();
                    }
                }).show();
    }

    public static AlertDialog getNotice(Context context, String content) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_notice, null);
        builder.setView(dialogView);
        AlertDialog dialog = builder.create();
        TextView tvContent = dialogView.findViewById(R.id.tv_content);
        Button btnConfirm = dialogView.findViewById(R.id.btn_confirm);
        tvContent.setText(content);
        ClickUtil.click(300, btnConfirm, view -> dialog.dismiss());
        return dialog;
    }

    public interface OnTipSure {
        void onSure();
    }

    public interface OnTipSurePublish {
        void onSure(String pwd);
    }
}
